package cn.edu.sdu.sol.material_management_system.repository;

import cn.edu.sdu.sol.material_management_system.model.po.Room;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.Optional;

@Repository
public interface RoomRepository extends JpaRepository<Room, Integer> {

    @Query(value = "from Room where stationId=?1")
    Optional<Room> findRoomByRoomId(Integer roomId);

    @Query(value = "SELECT COUNT(*) FROM Room", nativeQuery = true)
    int countRooms();
}

